package com.yanqu.road.server.channelserver.cmd.activity.luckydraw;

import com.yanqu.road.entity.activity.luckydraw.LuckyDrawParam;
import com.yanqu.road.logic.pb.LuckyDrawPb2;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LuckyDrawProto;
import com.yanqu.road.server.channelserver.cmd.ChannelCommand;
import com.yanqu.road.server.channelserver.manager.activity.luckydraw.ChannelLuckyDrawActivity;
import com.yanqu.road.server.channelserver.manager.activity.luckydraw.ChannelLuckyDrawMgr;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.protocol.ChannelProtocol;

@Cmd(code = ChannelProtocol.N_LUCKY_DRAW_GET_USER_DATA, desc = "")
public class ChannelLuckyDrawGetUserDataCmd extends ChannelCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        LuckyDrawProto.ChannelLuckyDrawGetUserDataReqMsg reqMsg = LuckyDrawProto.ChannelLuckyDrawGetUserDataReqMsg.parseFrom(packet.getBytes());
        LuckyDrawProto.ChannelLuckyDrawKeyMsg key = reqMsg.getKey();
        LuckyDrawParam param = LuckyDrawPb2.parseChannelLuckyDrawKeyMsg(key);
        ChannelLuckyDrawActivity activity = ChannelLuckyDrawMgr.getActivity(key.getActivityId());
        if (activity == null) {
            log.error("can not find LuckyDraw activity! activityId {}.", key.getActivityId());
            return false;
        }

        activity.getUserDataByCmd(param);
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
